import React from 'react';
import { Upload, message, Button, Icon } from 'antd';
import { getAuthority } from '../../utils/authority';

const props = {
  name: 'file',
  action: 'http://192.168.132.1:9000/file/tms-file/upload',
  withCredentials: true,

  headers: {
    token: getAuthority(),
  },
  onChange(info) {
    if (info.file.status !== 'uploading') {
      console.log(info.file, info.fileList);
    }
    if (info.file.status === 'done') {
      message.success(`${info.file.name} file uploaded successfully`);
    } else if (info.file.status === 'error') {
      message.error(`${info.file.name} file upload failed.`);
    }
  },
};
 class FileUpload extends React.Component {



  render(){
    return(
      <Upload {...props} withCredentials={true}>
        <Button>
          <Icon type="upload" /> Click to Upload
        </Button>
      </Upload>
    )
  }

}

export default FileUpload;
